xx <- c(-3,-3,-2,-1,0,1,3,5,5)
yy <- c(7,3,5,1,-1,-3,-8,-8,-9)
cor(xx,yy)
plot(xx,yy, col="black", bg="black", pch=21, cex=1.5)
grid()
beta <- (mean(xx*yy) - mean(xx)*mean(yy))/(mean(xx*xx) - (mean(xx))*(mean(xx)))
alpha <- mean(yy) - beta*mean(xx)
z <- seq(-5,5,by=0.1)
points(z,beta*z+alpha, col="red", type="l")